Skip to content

Conversation

@dadamssg
Copy link
Contributor

@dadamssg dadamssg commented Nov 13, 2025

This adds callsite revalidation optout as brought up here: #10006

<Form method='post' defaultShouldRevalidate={false}>
fetcher.submit(target, {
  method: 'post',
  defaultShouldRevalidate: false
}

If this new value evaluates to false, it will skip calling the currently matched route's shouldRevalidate functions entirely, superseding and short-circuiting them.

@changeset-bot
Copy link

changeset-bot bot commented Nov 13, 2025

🦋 Changeset detected

Latest commit: 0715840

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
react-router Patch
@react-router/architect Patch
@react-router/cloudflare Patch
@react-router/dev Patch
react-router-dom Patch
@react-router/express Patch
@react-router/node Patch
@react-router/serve Patch
@react-router/fs-routes Patch
@react-router/remix-routes-option-adapter Patch
create-react-router Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@dadamssg dadamssg force-pushed the callsite-revalidation-optout branch from 23aff25 to 3ee7f30 Compare November 13, 2025 19:30
@dadamssg dadamssg force-pushed the callsite-revalidation-optout branch 2 times, most recently from a015f8b to 8929118 Compare November 20, 2025 15:52
@dadamssg dadamssg force-pushed the callsite-revalidation-optout branch from 8929118 to 9c211ae Compare November 20, 2025 16:16
@brophdawg11
Copy link
Contributor

General approach is looking good on a quick pass! A few minor comments - I'll do some deeper testing once those are updated

@dadamssg dadamssg force-pushed the callsite-revalidation-optout branch from d879db7 to 67ee043 Compare November 20, 2025 17:17
@dadamssg
Copy link
Contributor Author

Updated per your comments. good calls 👍

@brophdawg11
Copy link
Contributor

This is looking awesome! I made some very minor updates inside the router, and instead of testing locally with an app I just wrote a bunch of tests and they all passed so I think we're good on that front. I prefixed it with unstable_ for initial release. I'll get an experimental cut or some early alpha testing in a bit here.

Comment on lines +5061 to +5069
let defaultShouldRevalidate: boolean;
if (typeof callSiteDefaultShouldRevalidate === "boolean") {
// Use call-site value verbatim if provided
defaultShouldRevalidate = callSiteDefaultShouldRevalidate;
} else if (shouldSkipRevalidation) {
defaultShouldRevalidate = false;
} else {
defaultShouldRevalidate = isRevalidationRequired;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only functional change - we also need to apply this to any fetcher.load revalidation checks

@brophdawg11
Copy link
Contributor

I just kicked off an experimental release from this branch for some alpha testing: 0.0.0-experimental-2d8f5c807

@dadamssg
Copy link
Contributor Author

woohoo! Thanks for carrying it to the finish line @brophdawg11!

@brookslybrand
Copy link
Contributor

Am I missing something or holding it wrong?

stackblitz

wat.yafw.balanced.mp4

@dadamssg
Copy link
Contributor Author

dadamssg commented Nov 22, 2025

ooh good catch @brookslybrand. It's because you're actually exporting a shouldRevalidate in the route. We I didn't check for that 🙃 It looks like Matt did add a test explicitly for that. I'll have to dig into why the test behaves differently.

Problem is here @brophdawg11.

// Single fetch revalidates by default, so override the RR default value which
// matches the multi-fetch behavior with `true`
if (ssr && route.shouldRevalidate) {
let fn = route.shouldRevalidate;
return (opts: ShouldRevalidateFunctionArgs) =>
fn({ ...opts, defaultShouldRevalidate: true });
}

The existence of this code and the comment makes me believe it might not be as simple as just deleting though. 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants